package com.fansl.allround.open.api.constant.enums.juhe;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * @author fansl
 * @Description: 新闻类型
 * @date 2019/9/9 17:21
 */
@Getter
@AllArgsConstructor
public enum NewsTypeEnum {

    Top("top","头条"),
    SheHui("shehui","社会"),
    GuoNei("guonei","国内"),
    GuoJi("guoji","国际"),
    YuLe("yule","娱乐"),
    TiYu("tiyu","体育"),
    JunShi("junshi","军事"),
    KeJi("keji","科技"),
    CaiJing("caijing","财经"),
    ShiShang("shishang","时尚"),
            ;
    private String name;
    private String desc;

    public static NewsTypeEnum getByName(String name){
        for (NewsTypeEnum enums:Arrays.asList(NewsTypeEnum.values())) {
            if(enums.getName().equals(name)){
                return enums;
            }
        }
        return Top;
    }
    public static NewsTypeEnum getByDesc(String desc){
        for (NewsTypeEnum enums:Arrays.asList(NewsTypeEnum.values())) {
            if(enums.getDesc().equals(desc)){
                return enums;
            }
        }
        return Top;
    }
}
